package org.example.coursemangementserver.common.context;

/**
 * ThreadLocal用于在同一线程类共享数据
 * @author 12438
 */
public class BaseContext {
    //该技术常用的三个方法
    //set,get,remove
    public static ThreadLocal<ThreadLocalInfo> threadLocal = new ThreadLocal<>();

    public static void setCurrentUser(ThreadLocalInfo user) {
        threadLocal.set(user);
    }

    public static ThreadLocalInfo getCurrentUser() {

        return threadLocal.get();
    }
    public static void removeCurrentUser() {
        threadLocal.remove();
    }

}
